/* GUI CONVERTED from rwarmt.p (converter v1.76) Fri Sep 21 01:05:12 2001 */
/* rwarmt.p - PART SITE ALTERNATE ROUTING/BILL OF MATERIAL MAINTENANCE        */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.7.1.5 $                                                               */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 6.0      LAST MODIFIED: 04/15/91   BY: emb *D342*                */
/* REVISION: 7.0      LAST MODIFIED: 04/29/92   BY: emb *F457*                */
/* REVISION: 7.3      LAST MODIFIED: 02/24/93   BY: sas *G729*                */
/* REVISION: 7.3      LAST MODIFIED: 05/19/93   BY: pma *GB17*                */
/* REVISION: 7.5      LAST MODIFIED: 10/20/94   BY: mwd *J034*                */
/* REVISION: 7.5      LAST MODIFIED: 02/17/95   BY: tjs *J020*                */
/* REVISION: 8.5      LAST MODIFIED: 07/30/96   BY: *J12T* Sue Poland         */

/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb                */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Revision: 1.7.1.4   BY: Vandna Rohira         DATE: 08/27/01  ECO: *M1JF*  */
/* $Revision: 1.7.1.5 $    BY: Vandna Rohira         DATE: 09/20/01  ECO: *N12S*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* DISPLAY TITLE */
{mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rwarmt_p_1 "Bill of Material"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions *********   */

define variable del-yn like mfc_logical initial yes.
define variable part   like ptr_part.
define variable site   like ptr_site.


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
ptr_part       colon 20
   ptr_site       colon 58
   pt_desc1       colon 20
   pt_draw        colon 58
   pt_desc2       at 22 no-label
   pt_part_type   colon 58
   pt_um          colon 20
   pt_status      colon 58
 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
ptr_routing     colon 20
   ptr_bom_code    colon 20 label {&rwarmt_p_1}
 SKIP(.4)  /*GUI*/
with frame c side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-c-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame c = F-c-title.
 RECT-FRAME-LABEL:HIDDEN in frame c = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame c =
  FRAME c:HEIGHT-PIXELS - RECT-FRAME:Y in frame c - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME c = FRAME c:WIDTH-CHARS - .5.  /*GUI*/


/* SET EXTERNAL LABELS */
setFrameLabels(frame c:handle).

mainloop:
repeat:
/*GUI*/ if global-beam-me-up then undo, leave.

   view frame a.
   view frame c.

   do with frame a on endkey undo, leave mainloop:

      prompt-for
         ptr_part
         ptr_site
      editing:

         /* SET GLOBAL PART AND SITE VARIABLES */
         assign
            global_part = input ptr_part
            global_site = input ptr_site.

         if frame-field = "ptr_part"
         then do:
            /* FIND NEXT/PREVIOUS RECORD */
            {mfnp.i
                ptr_det
                ptr_part
                ptr_part
                ptr_site
                ptr_site
                ptr_part}
         end. /* IF frame-field = "ptr_part" */
         else if frame-field = "ptr_site"
         then do:
            /* FIND NEXT/PREVIOUS RECORD */
            {mfnp01.i
                ptr_det
                ptr_site
                ptr_site
                ptr_part
                "input ptr_part"
                ptr_part}
         end. /* IF frame-field = "ptr_site" */
         else do:
            status input.
            readkey.
            apply lastkey.
         end. /* ELSE DO */
         if recno <> ?
         then do:
            for first pt_mstr
               fields (pt_desc1 pt_desc2     pt_draw   pt_joint_type
                       pt_part  pt_part_type pt_status pt_um)
               where pt_part = ptr_part
            no-lock:
            end. /* FOR FIRST pt_mstr */
            display
               ptr_part
               ptr_site
               with frame a.
            display
               pt_desc1
               pt_desc2
               pt_um
               pt_draw
               pt_part_type
               pt_status
            with frame a.

            display
               ptr_routing
               ptr_bom_code
            with frame c.

         end. /* IF recno <> ? */
      end.  /* EDITING */

      for first pt_mstr
         fields (pt_desc1 pt_desc2     pt_draw   pt_joint_type
                 pt_part  pt_part_type pt_status pt_um)
         where pt_part = input ptr_part
      no-lock:
      end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* FOR FIRST pt_mstr */

      for first si_mstr
         fields (si_site)
         where si_site = input ptr_site
      no-lock:
      end. /* FOR FIRST si_mstr */

      if not available si_mstr
      then do:
         /* SITE DOES NOT EXIST */
         {pxmsg.i &MSGNUM=708 &ERRORLEVEL=3}
         next-prompt ptr_site.
         undo, retry.
      end. /* IF NOT AVAILABLE si_mstr */

      display
         pt_part @ ptr_part
         si_site @ ptr_site
         pt_desc1
         pt_desc2
         pt_um
         pt_draw
         pt_part_type
         pt_status
      with frame a.

      if available si_mstr
      then do:
         {gprun.i ""gpsiver.p""
            "(input si_site, input recid(si_mstr), output return_int)"}
/*GUI*/ if global-beam-me-up then undo, leave.

      end. /* IF AVAILABLE si_mstr */
      else do:
         {gprun.i ""gpsiver.p""
            "(input (input ptr_site),
              input ?,
              output return_int)"}
/*GUI*/ if global-beam-me-up then undo, leave.

      end. /* IF NOT AVAILABLE si_mstr */
      if return_int = 0
      then do:
         /*USER DOES NOT HAVE ACCESS TO THIS SITE */
         {pxmsg.i &MSGNUM=725 &ERRORLEVEL=3}
         next-prompt ptr_site with frame a.
         undo mainloop, retry.
      end. /* IF return_int = 0 */

      repeat with frame c:
/*GUI*/ if global-beam-me-up then undo, leave.

         prompt-for ptr_routing with frame c editing:
            if frame-field = "ptr_routing"
            then do:
               /* FIND NEXT/PREVIOUS RECORD */
               {mfnp05.i
                   ptr_det
                   ptr_part
                   "ptr_part = input ptr_part and
                   ptr_site = input ptr_site"
                   ptr_routing
                   "input ptr_routing" }
            end. /* IF frame-field = "ptr_routing" */
            else do:
               readkey.
               apply lastkey.
            end. /* IF frame-field <> "ptr_routing" */
            if recno <> ?
            then do:
               display
                  ptr_routing
                  ptr_bom_code
               with frame c.
            end. /* IF recno <> ? */
         end.     /* editing */

         /* ADD/MOD/DELETE  */
         del-yn = no.

         for first ro_det
            fields (ro_fsm_type ro_routing)
            where ro_routing =   input ptr_routing
         no-lock:
            /* PREVENT USE OF SERVICE ROUTINGS */
            if ro_fsm_type = "FSM"
            then do:
               /* THIS IS A SERVICE ROUTING, NOT A STANDARD RTG */
               {pxmsg.i &MSGNUM=7423 &ERRORLEVEL=3}
               undo, retry.
            end. /* IF ro_fsm_type = "FSM" */

         end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* FOR FIRST ro_det */

         find ptr_det
            using ptr_part
            and   ptr_site
            and   ptr_routing
         exclusive-lock no-error.
         if not available ptr_det
         then do:

            /* NEW ITEM */
            {pxmsg.i &MSGNUM=1 &ERRORLEVEL=1}
            create ptr_det.
            assign
               ptr_part
               ptr_site
               ptr_routing.

         end. /* IF NOT AVAILABLE ptr_det */

         ststatus = stline[2].
         status input ststatus.

         if ptr_routing > ""
            and not can-find (first ro_det where ro_routing = ptr_routing)
         then do:
            /* ROUTING DOES NOT EXIST */
            {pxmsg.i &MSGNUM=126 &ERRORLEVEL=2}
         end. /* IF ptr_routing > "" */

         do on error undo, retry with frame c:
/*GUI*/ if global-beam-me-up then undo, leave.


            set
               ptr_bom_code
               go-on (F5 CTRL-D) with frame c.

            /* DELETE */
            if lastkey    = keycode("F5")
               or lastkey = keycode("CTRL-D")
            then do:
               del-yn = yes.
               /* PLEASE CONFIRM DELETE */
               {pxmsg.i &MSGNUM=11 &ERRORLEVEL=1 &CONFIRM=del-yn}
               if del-yn = no then undo, retry.

               delete ptr_det.
               clear frame c.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame c = F-c-title.
               del-yn = no.
            end. /* IF LASTKEY = KEYCODE("F5") */

            else
            if ptr_bom_code > "" and ptr_bom_code <> ptr_part
            then do:

               for first bom_mstr
                  fields (bom_fsm_type bom_parent)
                  where bom_parent = ptr_bom_code
               no-lock:

                  /* PREVENT USE OF SERVICE BOM'S */
                  if bom_fsm_type = "FSM"
                  then do:
                     /* THIS IS AN SSM BILL OF MAT'L... */
                     {pxmsg.i &MSGNUM=7487 &ERRORLEVEL=3}
                     undo, retry.
                  end. /* IF bom_fsm_type = "FSM" */

               end. /* FOR FIRST bom_mstr */

               for first ps_mstr
                  fields (ps_comp ps_par ps_ps_code)
                  where ps_par     = ptr_part
                  and   ps_comp    = ptr_bom_code
                  and   ps_ps_code = "A"
               no-lock:
               end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* FOR FIRST ps_mstr */

               if not available (ps_mstr)
               then do:
                  /* APPROVED ALTERNATE PROD. STRUC. DOES NOT EXIST */
                  {pxmsg.i &MSGNUM=549 &ERRORLEVEL=3}
                  undo, retry.
               end. /* IF NOT AVAILABLE ps_mstr */

               for first pt_mstr
                  fields (pt_desc1 pt_desc2     pt_draw   pt_joint_type
                          pt_part  pt_part_type pt_status pt_um)
                  where pt_part = ptr_bom_code
               no-lock:
                  if pt_joint_type = "5"
                  then do:
                     /* BASE PROCESS MAY NOT BE DEFINED IN  */
                     /* AN ALTERNATE STRUCTURE              */
                     {pxmsg.i &MSGNUM=6532 &ERRORLEVEL=4}
                     undo, retry.
                  end. /* IF pt_joint_type = "5" */
               end. /* FOR FIRST pt_mstr */

               ptr_bom_code = ps_comp.
            end.  /* IF ptr_bom_code > "" ... */
         end.     /* DO ON ERROR WITH FRAME c */

         status input.
      end.     /* REPEAT WITH FRAME c */
   end.    /* DO WITH FRAME a */
end.   /* MAINLOOP REPEAT */
status input.
